perm filename HOSTAB.MID[NET,MRC]1 blob sn#314821 filedate 1977-11-03 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	title HOSTAB  Host table printer
C00005 00003	 I/O subroutines
C00007 00004	 Start of program
C00011 00005	hstprt:	skipg y,hsttab(a)		 get number of host
C00016 ENDMK
C⊗;
title HOSTAB  Host table printer

; Mark Crispin, SU-AI, November 1977
; Adapted from the ITS version

.insrt MACROS[1,MRC]

; The format of the ITS host table is:
;
; word 0	SIXBIT /HOSTS1/
; word 1	SIXBIT /HOSTS/
; word 2	FN2 of HOSTS file which this was compiled from.
; word 3	UNAME of person who compiled this generation of the host table
; word 4	Date of compilation as sixbit YYMMDD
; word 5	Time of compilation as sixbit HHMMSS
; word 6	Address in file of NAME table.
; word 7	Address in file of NUMBER table.
;
; NUMBERS table:
; word 0	Number of entries in this table.
; word 1	Number of words per entry (currently 3).
; followed by entries, in order by host number.
; Each entry looks like this:
;   entry word 0	host number
;   entry word 1	LH  pointer to system name (ITS, TIP, TENEX, etc.)
;			May be 0 => not known.
;   entry word 1  RH  pointer to official name of host.
;   entry word 2  LH  flags:
;	4.9 1 => server site.
;   entry word 2  RH  pointer to machine name (PDP10, etc).
;			May be 0 => not known.
;
; NAMES table:
; word 0	Number of entries
; followed by one word entries, sorted by the host name treated as a vector of
; signed integers, looking like:
; bit 4.9	1 => this is official name of the host.
; rest of LH	address in file of NUMBERS table entry for this host.
; RH		pointer to host name

; Host, system and machine names are ASCIZ strings, all letters upper case.
; The strings are stored before, after and between the NAME and NUMBER tables.

acdef. [x y z a b c]			; accumulators

nd. pdllen==50.				; push down list length

pdl:	block pdllen			; push down list
; I/O subroutines

; NOUT numeric output
; accepts in x:	base to use for outputting the number
;	     y:	number to be output
; returns:  +1:	always, with y and z clobbered

nout=call .
	idivi y,(x)			; get a digit
	save z				; save the lowest order digit left
	caxe y,%zeros			; got them all?
	 nout				; nope
	retr y				; get a digit to output
	addx y,"0			; convert to ASCII
	outchr y			; output it
	return				; and return

; SOUT string output
; accepts in x:	pointer to string (0 in LH means ASCIZ string)
; returns   +1:	always, with updated string pointer in x; 0 clobbered

sout=call .
	txnn x,%lhalf			; is there a left half?
	 hrli x,440700			; no, assume ASCII
	store %zeros,strlen'		; initialize string length
	ildb x				; get a character
	jumpe [return]			; return if null
	aos strlen'			; bump counter
	outchr				; and output character
	jrst .-4			; and try next
; Start of program

hostab:	move p,[pdl(-pdllen)]		; load PDP
	open [17 ? 'DSK,, ? 0]		; get a disk channel
	 jrst 4,.-1			; failed?
	movx x,'HOSTS1			; fn1
	movx y,('BIN)			; fn2
	movx z,%zeros			; protection trash
	movx a,'NETMRC			; ppn
	lookup x			; get host table
	 jrst [	outstr [asciz/Host table gone!/]
		jrst 4,.-1]
	movs x,a			; get -size
	movns x				; positive
	addi x,hsttab			; offset for address
	core x,				; get necessary core
	 jrst 4,.-1
	hrri a,hsttab-1			; make IOWD pointer
	movx b,%zeros			; and stop code
	in a				; read file in
	 skipn x,hsttab			; check first word of host table
	  jrst 4,.-1			; didn't read it all or bad?
	caxe x,'HOSTS1			; right first word?
	 jrst 4,.-1			; bad file?
	outstr [asciz/Host table #/]
	skipn x,hsttab+2		; get version of the HOSTS file
	 jrst 4,.-1			; blank version?
htbver:	movx y,%zeros			; zap where character will go
	rotc x,6			; siphon off a character
	addx y,<" >			; convert to ASCII
	outchr y			; output it
	jumpn x,htbver			; continue if still more
	outstr [asciz/ generated by /]
	skipn x,hsttab+3		; get UNAME of creator
	 jrst 4,.-1			; null UNAME?
htbunm:	movx y,%zeros			; zap where character will go
	rotc x,6			; gobble a character
	addx y,<" >			; ASCIIify
	outchr y			; output
	jumpn x,htbunm			; continue if more
	outstr [asciz/ on /]
	skipn x,hsttab+4		; get compilation date
	 jrst 4,.-1			; null creation date?
	rot x,12.			; put year last
repeat 3,[
 repeat 2,[
	  movx y,%zeros			; zap character
	  rotc x,6			; gobble a character
	  addx y,<" >			; ASCIIify
	  outchr y			; output the character
 ]
 ifn .rpcnt-2,outchr ["/]		; output a slash
 .else	 outchr [" ]			; output a space last time
]
	skipn x,hsttab+5		; get compilation time
	 jrst 4,.-1			; null compilation time?
repeat 3,[
 repeat 2,[
	  movx y,%zeros			; zap character
	  rotc x,6			; gobble a character
	  addx y,<" >			; ASCIIify
	  outchr y			; output the character
 ]
 ifn .rpcnt-2,outchr [":]		; delimiter
]
	outstr [asciz/

Host #	Oct #	Official Name	Machine		System

/]
	skipg a,hsttab+7		; load address of NUMBERS table
	 jrst 4,.-1			; invalid address?
	skipg b,hsttab(a)		; load number of entries
	 jrst 4,.-1			; invalid number of entries?
	skipg c,hsttab+1(a)		; load number of words/entry
	 jrst 4,.-1			; invalid number of words?
	addx a,2			; point now to first entry
hstprt:	skipg y,hsttab(a)		; get number of host
	 jrst 4,.-1			; funny host number?
	movx x,"*			; assume a server
	skipl hsttab+2(a)		; but is it really?
	 movx x,<" >			; nope, a user
	outchr x ? outchr [" ]		; initial heading
	caxge y,1000.			; four digit number?
	 outchr [" ]			; three or less
	caxge y,100.			; three digit number?
	 outchr [" ]			; two or less
	caxge y,10.			; two digit number?
	 outchr [" ]			; one digit
	movx x,10.			; load up decimal base
	nout				; output it
	outchr [↑I]			; go to next field
	skipg y,hsttab(a)		; get the number again
	 outchr				; how can this happen??
	caxge y,1000			; four digit number?
	 outchr [" ]			; three or less
	caxge y,100			; three digit number?
	 outchr [" ]			; two or less
	caxge y,10			; two digit number?
	 outchr [" ]			; one digit
	movx x,8.			; load up octal base
	nout				; output it
	outchr [↑I]			; go to next field
	hrrz x,hsttab+1(a)		; get name of host
	jumpe x,[jrst 4,.]		; null host pointer?
	addi x,hsttab			; convert to absolute address
	sout				; output the string
	skipn x,strlen'			; get length of string
	 jrst 4,.-1			; null host name?
	caxge x,8.			; more than one field length?
	 outchr [↑I]			; yes, another tab required
	outchr [↑I]			; output another tab
	hrrz x,hsttab+2(a)		; get machine host is
	jumpe x,[	movei x,[asciz/UNKNOWN/]; unknown name
			jrst .+2]	; and continue
	addi x,hsttab			; convert to absolute address
	move y,(x)			; get first word of machine name
	andx y,777777700000		; get first three characters
	caxn y,ascii/PDP/		; is this a PDP-nn?
	 jrst [	ldb y,[100700,,(x)]	; yes, get fourth character
		caxn y,"-		; is it a dash?
		 jrst .+1		; yes (foo, somebody lost!)
		save x			; save current pointer
		outstr [asciz/PDP-/]
		retr x			; get current pointer back
		hrli x,170700		; kludge up byte pointer after PDP
		jrst .+1]		; what a crock!
	sout				; and output it
	skipn x,strlen'			; get length of string
	 jrst 4,.-1			; null host name?
	caxge x,8.			; more than one field length?
	 outchr [↑I]			; yes, another tab needed
	outchr [↑I]			; output a delimiting tab
	hlrz x,hsttab+1(a)		; get system host has
	jumpe x,[	movei x,[asciz/UNKNOWN/]; unknown system
			jrst .+2]	; and continue
	addi x,hsttab			; convert to absolute address
	sout				; and output it
	outstr [asciz/
/]
	addi a,(c)			; go to next entry in the table
	sojg b,hstprt			; loop for next entry
	outstr [asciz/
* means this site is a server
/]
	exit				; suicide

; Generate literals

	variables ? constants

hsttab:					; start of host table

	end HOSTAB